#if !defined(IMGLIB_WINBMP_H)
#define IMGLIB_WINBMP_H

#include "imglib/bitmap.h"
#include "imglib/imageclass_decl.h"
#include <windows.h>

namespace img {

#pragma pack (push, 2)

template <class R>
struct bitmap_info;

template <>
struct bitmap_info<bitmap> {
	BITMAPINFOHEADER	bmiHeader;
	RGBQUAD				bmiColors[2];
};

template <>
struct bitmap_info<mono_byte_image> {
	BITMAPINFOHEADER	bmiHeader;
	RGBQUAD				bmiColors[256];
};

template <>
struct bitmap_info<small_byte_image> {
	BITMAPINFOHEADER	bmiHeader;
};

template <>
struct bitmap_info<byte_image> {
	BITMAPINFOHEADER	bmiHeader;
};

#pragma pack (pop)

BITMAPINFO * ComposeBitmapInfo(bitmap_info<bitmap> & info, const bitmap & bmp, COLORREF foreground = RGB(255,255,255), COLORREF background = RGB(0,0,0));
BITMAPINFO * ComposeBitmapInfo(bitmap_info<mono_byte_image> & info, const mono_byte_image & img);
BITMAPINFO * ComposeBitmapInfo(bitmap_info<small_byte_image> & info, const small_byte_image & img);
BITMAPINFO * ComposeBitmapInfo(bitmap_info<byte_image> & info, const byte_image & img);

void DrawBitmap(HDC	hDC, int xd, int yd, int wd, int hd, int xs, int ys, const bitmap & bmp, COLORREF foreground, COLORREF background);

void StretchBitmap(HDC hDC, int xd, int yd, int wd, int hd, int xs, int ys,	int ws,	int hs,	const bitmap & bmp, COLORREF foreground, COLORREF background, long ROP = SRCCOPY);

void BlendBitmap(HDC hDC, int xd, int yd, int wd, int hd, int xs, int ys,	int ws,	int hs,	const bitmap & bmp, COLORREF foreground, COLORREF background, unsigned char alpha);

class BitmapBlender {
private:
	extent<size_type>	_dim;
	HBITMAP				_hbmp, _hold;
	HDC					_hdc;
public:
	BitmapBlender();
	~BitmapBlender();
	void operator () (HDC hDC, int xd, int yd, int wd, int hd, int xs, int ys, int ws, int hs, const bitmap & bmp, COLORREF foreground, COLORREF background, unsigned char alpha);
};

} //namespace img


#endif // IMGLIB_WINBMP_H
